package com.linkoog.devtools.project_manager.settings;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.util.xmlb.XmlSerializerUtil;
import com.linkoog.devtools.project_manager.settings.domain.ProjectDirectory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.TreeSet;

import com.intellij.openapi.components.Storage;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.PersistentStateComponent;

@State(name = "ProjectSwitcher", storages = { @Storage("project-switcher.settings.xml") })
public class ProjectManagerSetting implements PersistentStateComponent<ProjectManagerSetting> {
    private TreeSet<ProjectDirectory> projectDirectorys = new TreeSet<>();

    private boolean forceProjectOneTab = false;

    public ProjectManagerSetting() {
    }

    public static ProjectManagerSetting getInstance(){
        return ApplicationManager.getApplication().getService(ProjectManagerSetting.class);
    }

    @Nullable
    public ProjectManagerSetting getState() {
        return this;
    }
    
    public void loadState(@NotNull final ProjectManagerSetting state) {
        XmlSerializerUtil.copyBean(state, this);
    }

    public TreeSet<ProjectDirectory> getProjectDirectorys() {
        return projectDirectorys;
    }

    public void setProjectDirectorys(TreeSet<ProjectDirectory> projectDirectorys) {
        this.projectDirectorys = projectDirectorys;
    }

    public boolean isForceProjectOneTab() {
        return forceProjectOneTab;
    }

    public void setForceProjectOneTab(boolean forceProjectOneTab) {
        this.forceProjectOneTab = forceProjectOneTab;
    }
}
